﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmTopics.aspx.cs" Inherits="WCrawler.frmTopics" %>
<%@ Register Src="~/Controls/ucTreeViewTopic.ascx" TagName="ucTreeViewTopic" TagPrefix="UserControl" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript" language="javascript">
        function changeCheckState() {
            try {
                var frm = document.forms[0];
                var i = 0;
                for (i = 0; i < frm.length; i++) {
                    if (frm.elements[i].id.indexOf('chkCheckItem') != -1) {
                        if (document.getElementById(frm.elements[i].id) != null) {
                            if (frm.elements[i].checked == false) {
                                frm.elements[i].checked = true;
                            } else {
                                frm.elements[i].checked = false;
                            } 
                        }
                    }
                }
            } catch (err) { }
        }
    </script>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="ForumThreadDetailsUpdatePanel" runat="server">
        <ContentTemplate>
            <div>
                <asp:TextBox ID="txtName" runat="server" Width="30%"></asp:TextBox>
                <asp:DropDownList ID="dropDownListParentThread" runat="server" 
                    DataSourceID="TopicLinqDataSource" DataTextField="TopicName" 
                    DataValueField="TopicId" AppendDataBoundItems="True" Width="20%" AutoPostBack="True">
                </asp:DropDownList>
                <asp:Button ID="btnAddThread" runat="server" Text="Add Thread" 
                    onclick="btnAddThread_Click" />
                <asp:Label ID="lblAddMessage" runat="server"></asp:Label>
                <asp:Button ID="btnUpdateKeywords" runat="server" Text="Update Keywords" />
            </div>
            <table style="width: 100%;">
                <tr>
                    <td valign="top">
                    <asp:PlaceHolder runat="server" ID="PlaceHolderTreeViewTopic">
                    <UserControl:ucTreeViewTopic id="ucTreeViewTopic" runat="server" OnBubbleIndexChanged="ucTreeViewTopic_SelectedIndexChanged"/>
                </asp:PlaceHolder> 
                    </td>
                    <td valign="top">
                        <asp:CheckBox ID="chkViewEdit" runat="server" AutoPostBack="True" 
                            oncheckedchanged="chkViewEdit_CheckedChanged" Text="View Edit?" />
                        <asp:Button ID="btnSubmitChanges" runat="server" 
                            onclick="btnSubmitChanges_Click" Text="Submit Changes" />
                        <asp:Label ID="lblUpdateMessage" runat="server"></asp:Label>
                        <asp:GridView ID="gridViewThread" runat="server" AutoGenerateColumns="False" 
        BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" 
        CellPadding="4" DataKeyNames="TopicId" Width="100%" 
        DataSourceID="TopicGridViewLinqDataSource" AllowSorting="True" 
                    onrowdatabound="gridViewForumThreadDetails_RowDataBound">
                            <Columns>
                            <asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="Center">
                                <HeaderTemplate>
                                <asp:CheckBox ID="chkHead" runat="server"
                                onclick="changeCheckState(this);" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkCheckItem" Runat="server" />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Topic">
                                <ItemTemplate>
                                    <asp:Label ID="lblTopicName" Visible='<%# !(bool) chkViewEdit.Checked %>' runat="server" Text='<% #Eval("TopicName")%>' Width="100%"> </asp:Label>
                                    <asp:TextBox ID="txtTopicName" Visible='<%# chkViewEdit.Checked %>' runat="server" Text='<% #Bind("TopicName")%>' Width="100%"> </asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                                <asp:TemplateField HeaderText="Parent">
                                    <ItemTemplate>
                                        <asp:Label ID="lblParentTopic" Visible='<%# !(bool) chkViewEdit.Checked %>' runat="server" Text='<% #Eval("Topic1.TopicName")%>' Width="100%"> </asp:Label>
                                        <asp:DropDownList ID="ParentTopicDropDownList" Visible='<%# chkViewEdit.Checked %>' runat="server" 
                                            DataSourceID="TopicLinqDataSource" DataTextField="TopicName" 
                                            DataValueField="TopicId" AppendDataBoundItems="true" Width="100%">
                                        </asp:DropDownList>
                                    </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="TopicOrder" SortExpression="TopicOrder">
                                <ItemTemplate>
                                    <asp:Label ID="lblTopicOrder" Visible='<%# !(bool) chkViewEdit.Checked %>' runat="server" Text='<% #Eval("TopicOrder")%>' Width="100%"> </asp:Label>
                                    <asp:TextBox ID="txtTopicOrder" Visible='<%# chkViewEdit.Checked %>' runat="server" Text='<% #Bind("TopicOrder")%>' Width="100%"> </asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Keywords" SortExpression="Keywords">
                                <ItemTemplate>
                                    <asp:Label ID="lblKeywords" Visible='<%# !(bool) chkViewEdit.Checked %>' runat="server" Text='<% #Eval("Keywords")%>' Width="100%"> </asp:Label>
                                    <asp:TextBox ID="txtKeywords" Visible='<%# chkViewEdit.Checked %>' runat="server" Text='<% #Bind("Keywords")%>' Width="100%"> </asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                            </Columns>
                            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                            <RowStyle BackColor="White" ForeColor="#003399" />
                            <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                            <SortedAscendingCellStyle BackColor="#EDF6F6" />
                            <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                            <SortedDescendingCellStyle BackColor="#D6DFDF" />
                            <SortedDescendingHeaderStyle BackColor="#002876" />
                        </asp:GridView>
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    
    <asp:LinqDataSource ID="TopicLinqDataSource" runat="server" 
        ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
        TableName="Topics" OrderBy="TopicOrder">
    </asp:LinqDataSource>
    
    <asp:LinqDataSource ID="TopicGridViewLinqDataSource" runat="server" 
        ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
        TableName="Topics" OrderBy="TopicOrder" 
        onselecting="TopicGridViewLinqDataSource_Selecting">
    </asp:LinqDataSource>
    
    <br />
    
</asp:Content>
